Page({
  data:{
    appId:'',
    appName:'',
    recordId:'',
    pageTitle:'',
    sections:[],
    status:'approved',
    statusText:'已通过',
    metaDate:'',
    metaApplicant:''
  },
  onLoad(options){
    const appId=options.appId||options.app_id||''
    const appName=decodeURIComponent(options.appName||options.app_name||'')
    const recordId=options.recordId||''
    this.setData({appId,appName,recordId})
    this.initPage()
  },
  initPage(){
    const title=`记录详情：${this.data.appName}`
    const sections=this.buildDetailByAppId(this.data.appId,this.data.recordId)
    const meta={date:'2025-11-25',applicant:'庄嘉豪'}
    this.setData({pageTitle:title,sections,metaDate:meta.date,metaApplicant:meta.applicant})
  },
  buildDetailByAppId(appId,recordId){
    const id=String(appId)
    const base=(pairs)=>[{id:'base',name:'基本信息',fields:pairs}]
    if(id==='38'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`差旅费报销-${recordId}`},
          {id:'applicant',label:'申请人',value:'庄嘉豪'},
          {id:'amount',label:'报销总额',value:'560.00'}
        ]}
      ]
    }
    return base([
      {id:'title',label:'标题',value:`通用申请-${recordId}`},
      {id:'applicant',label:'申请人',value:'庄嘉豪'}
    ])
  },
  onBack(){wx.navigateBack()}
})
